﻿using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using lindyaka.Domain.Entities;

namespace lindyaka.Domain
{
    public class DatabaseContext : DbContext
    {
        /** Entities */
        public DbSet<Role> Roles { get; set; }
        public DbSet<UserAccount> UserAccounts { get; set; }
        public DbSet<UserAccountRole> UserAccountRoles { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            /* Initializer */
            Database.SetInitializer(new DatabaseContextInitializer());

            /** Conventions */
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

            /** Configurations */
            modelBuilder.Configurations.Add(new Configurations.Role());
            modelBuilder.Configurations.Add(new Configurations.UserAccount());
            modelBuilder.Configurations.Add(new Configurations.UserAccountRole());

            base.OnModelCreating(modelBuilder);
        }
    }
}